﻿
namespace WeixinSDK
{
    public class CData : System.Xml.Serialization.IXmlSerializable
    {
        private string _value;

        public CData()
            : this(string.Empty)
        {
        }

        public CData(string value)
        {
            _value = value;
        }

        public static implicit operator CData(string value)
        {
            return new CData(value);
        }

        public static implicit operator string(CData cdata)
        {
            return cdata._value;
        }

        public override string ToString()
        {
            return _value;
        }

        #region IXmlSerializable

        public System.Xml.Schema.XmlSchema GetSchema()
        {
            return null;
        }

        public void ReadXml(System.Xml.XmlReader reader)
        {
            _value = reader.ReadElementString();
        }

        public void WriteXml(System.Xml.XmlWriter writer)
        {
            writer.WriteCData(_value);
        }

        #endregion
    }
}
